import { defineStore } from 'pinia'
import { computed, reactive } from 'vue'

export interface BookingConfig {
  mode: 'playwright' | 'request'
  dataSource: 'selected' | 'auto'
  concurrency: number
  headless: boolean
  monitorFirst: boolean
  monitorInterval: number
  monitorOnly: boolean
  unattended: boolean
  unattendedInterval: number
  preferredDates: string
  preferredTimes: string
  allowedStart: string
  allowedEnd: string
}

export const useBookingStore = defineStore('booking', () => {
  const config = reactive<BookingConfig>({
    mode: 'playwright',
    dataSource: 'selected',
    concurrency: 8,
    headless: false,
    monitorFirst: false,
    monitorInterval: 30,
    monitorOnly: false,
    unattended: false,
    unattendedInterval: 60,
    preferredDates: '',
    preferredTimes: '',
    allowedStart: '',
    allowedEnd: '',
  })

  const isPlaywright = computed(() => config.mode === 'playwright')

  return { config, isPlaywright }
}, { persist: true })
